package day240607.thread;

public class ThreadNewPath {
    public static void main(String[] args) {
        Thread thread1=new Thread1("1");
        //直接调用run方法，相当于普通方法的调用，而非开辟一条新路径
        thread1.run();
        //调用start方法，才是启动一条新的路径
        thread1.start();
      new Thread(() -> {
          for (int i = 0; i <10; i++) {
              System.out.println(Thread.currentThread().getName()+"----"+i);

          }
      }).start();
    }
}
class Thread1 extends Thread {
    public Thread1(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(this.getName() + "-----" + i);
        }
    }
}
// implements Runnable可以实现多个接口，而extends Thread只能实现单继承
//    class Thread2 implements Runnable{
//        @Override
//        public void run() {
//            for (int i = 0; i <20 ; i++) {
//                System.out.println(Thread.currentThread().getName()+"-----"+i);
//        }
//    }
//}